<template>
	<slot :controller="controller" :store="store" :model="model">
    <AppForm
		ref="editForm"
        v-bind="$attrs"
		:id="controlID"
		:name="model.codeName"
		:class="classNames"
		:data="store.data"
		>
        <AppAnchor v-if="store.anchorData.length > 0" :controlID="controlID" :anchorData="store.anchorData" />
        <div class="control-content app-control-form__content">
			<AppRow :layoutOpts="{selfLayout: 'TABLE_24COL',}">
				<AppCol
				    noRoot
				    :visible="store.detailModel.group1.visible"
				    :layoutOpts="{selfLayout: 'TABLE_24COL',parentLayout: 'TABLE_24COL',colMD: 24,}">
				    <template #default="{ slotClass, slotStyle }">
				        <slot name="group1" :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				            <AppFormGroup 
				                name="group1"
				                v-show="store.detailModel.group1.visible"
				                :slotClass="slotClass"
				                :slotStyle="slotStyle"
				                :layoutOpts="{selfLayout: 'TABLE_24COL',parentLayout: 'TABLE_24COL',colMD: 24,}"
				                :title="$t('CONTROL.DEFORM.IBIZORDERDETAIL.MAIN.GROUPPANEL.GROUP1', '订单明细基本信息')"
				                subCaption=""
				                :enableAnchor="false"
				                :showMoreItems="store.detailModel.group1.showMoreItems"
				                :showMoreMode="store.detailModel.group1.showMoreMode"
				                :infoGroupMode="false"
				                :titleBarCloseMode="0"
				                :showCaption="true"
				                :uIActionGroup="store.detailModel.group1.uIActionGroup"
				                @component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }">
				                <AppCol
				                    noRoot
				                    :visible="store.detailModel.ibizordername.visible"
				                    :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 6,colSM: 6,colXS: 6,}">
				                    <template v-slot:default="{ slotStyle, slotClass }">
				                        <slot name="ibizordername"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				                            <AppFormItem 
				                                name="ibizordername"
				                                :slotStyle="slotStyle"
				                                :slotClass="slotClass" 
				                                :label="$t('DEF.LNAME.IBIZORDERDETAIL.IBIZORDERNAME', '订单名称')"
				                                labelPos="LEFT" 
				                                :labelWidth="130" 
				                                :showLabel="true"
				                                :enableAnchor="false" 
				                                :rules="store.detailModel.ibizordername.valueRule"
				                                :emptyCaption="false">
				                                <div class="form-editor-container">
				                                    <slot name="ibizordernameEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
				                                        <AppDataPicker
				                                            valueItem="ibizorderid"
				                                            :context="store.context"
				                                            :viewParams="store.viewParams"
				                                            deMajorField="ibizordername"
				                                            deKeyField="ibizorderid"
				                                            pickUpView="IBIZOrderPickupView"
				                                            deCodeName="IBIZORDER"
				                                            :acParams="{ serviceName: 'IBIZOrder', interfaceName: 'FetchDefault' }"
				                                            v-bind="{ editorType: 'PICKER', AC: 'TRUE', PICKUPVIEW: 'TRUE' }"
				                                            style=""
				                                            name="ibizordername"
				                                            :disabled="store.detailModel.ibizordername.disabled"
				                                            :data="store.data"
				                                            :value="store.data.ibizordername"
				                                            @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
				                                        />
				                                    </slot>
				                                </div>
				                            </AppFormItem>
				                        </slot>
				                    </template>
				                </AppCol>
				                <AppCol
				                    noRoot
				                    :visible="store.detailModel.ibizuniproductname.visible"
				                    :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 6,colSM: 6,colXS: 6,}">
				                    <template v-slot:default="{ slotStyle, slotClass }">
				                        <slot name="ibizuniproductname"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				                            <AppFormItem 
				                                name="ibizuniproductname"
				                                :slotStyle="slotStyle"
				                                :slotClass="slotClass" 
				                                :label="$t('CONTROL.DEFORM.IBIZORDERDETAIL.LOGIC_0007.FORMITEM.IBIZUNIPRODUCTNAME', '产品（查询计数检查）')"
				                                labelPos="LEFT" 
				                                :labelWidth="180" 
				                                :showLabel="true"
				                                :enableAnchor="false" 
				                                :rules="store.detailModel.ibizuniproductname.valueRule"
				                                :emptyCaption="false">
				                                <div class="form-editor-container">
				                                    <slot name="ibizuniproductnameEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
				                                        <AppDataPicker
				                                            valueItem="ibizuniproductid"
				                                            :context="store.context"
				                                            :viewParams="store.viewParams"
				                                            deMajorField="ibizuniproductname"
				                                            deKeyField="ibizuniproductid"
				                                            pickUpView="IBIZUNIProductPickupView"
				                                            deCodeName="IBIZUNIPRODUCT"
				                                            :acParams="{ serviceName: 'IBIZUNIProduct', interfaceName: 'FetchDefault' }"
				                                            v-bind="{ editorType: 'PICKER', AC: 'TRUE', PICKUPVIEW: 'TRUE' }"
				                                            style=""
				                                            name="ibizuniproductname"
				                                            :disabled="store.detailModel.ibizuniproductname.disabled"
				                                            :data="store.data"
				                                            :value="store.data.ibizuniproductname"
				                                            @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
				                                        />
				                                    </slot>
				                                </div>
				                            </AppFormItem>
				                        </slot>
				                    </template>
				                </AppCol>
				                <AppCol
				                    noRoot
				                    :visible="store.detailModel.unit.visible"
				                    :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 6,colSM: 6,colXS: 6,}">
				                    <template v-slot:default="{ slotStyle, slotClass }">
				                        <slot name="unit"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				                            <AppFormItem 
				                                name="unit"
				                                :slotStyle="slotStyle"
				                                :slotClass="slotClass" 
				                                :label="$t('DEF.LNAME.UNIT', '单位')"
				                                labelPos="LEFT" 
				                                :labelWidth="130" 
				                                :showLabel="true"
				                                :enableAnchor="false" 
				                                :rules="store.detailModel.unit.valueRule"
				                                :emptyCaption="false">
				                                <div class="form-editor-container">
				                                    <slot name="unitEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
				                                        <AppSpan
				                                            :context="store.context"
				                                            :viewParams="store.viewParams"
				                                            :dataType="25"
				                                            v-bind="{ editorType: 'SPAN', }"
				                                            deMajorField=""
				                                            editorType="SPAN"
				                                            style=""
				                                            name="unit"
				                                            noValueShowMode="STYLE1"
				                                            :value="store.data.unit"
				                                        />
				                                    </slot>
				                                </div>
				                            </AppFormItem>
				                        </slot>
				                    </template>
				                </AppCol>
				                <AppCol
				                    noRoot
				                    :visible="store.detailModel.unitprice.visible"
				                    :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 6,colSM: 6,colXS: 6,}">
				                    <template v-slot:default="{ slotStyle, slotClass }">
				                        <slot name="unitprice"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				                            <AppFormItem 
				                                name="unitprice"
				                                :slotStyle="slotStyle"
				                                :slotClass="slotClass" 
				                                :label="$t('DEF.LNAME.UNITPRICE', '单价X')"
				                                labelPos="LEFT" 
				                                :labelWidth="180" 
				                                :showLabel="true"
				                                :enableAnchor="false" 
				                                :rules="store.detailModel.unitprice.valueRule"
				                                :emptyCaption="false">
				                                <div class="form-editor-container">
				                                    <slot name="unitpriceEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
				                                        <AppSpan
				                                            :context="store.context"
				                                            :viewParams="store.viewParams"
				                                            :dataType="7"
				                                            v-bind="{ editorType: 'SPAN', }"
				                                            deMajorField=""
				                                            editorType="SPAN"
				                                            style=""
				                                            name="unitprice"
				                                            noValueShowMode="STYLE1"
				                                            :value="store.data.unitprice"
				                                        />
				                                    </slot>
				                                </div>
				                            </AppFormItem>
				                        </slot>
				                    </template>
				                </AppCol>
				                <AppCol
				                    noRoot
				                    :visible="store.detailModel.quantity.visible"
				                    :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 6,colSM: 6,colXS: 6,}">
				                    <template v-slot:default="{ slotStyle, slotClass }">
				                        <slot name="quantity"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				                            <AppFormItem 
				                                name="quantity"
				                                :slotStyle="slotStyle"
				                                :slotClass="slotClass" 
				                                :label="$t('DEF.LNAME.QUANTITY', '数量')"
				                                labelPos="LEFT" 
				                                :labelWidth="130" 
				                                :showLabel="true"
				                                :enableAnchor="false" 
				                                :rules="store.detailModel.quantity.valueRule"
				                                :emptyCaption="false">
				                                <div class="form-editor-container">
				                                    <slot name="quantityEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
				                                        <AppInput
				                                            v-bind="{ editorType: 'TEXTBOX', }"
				                                            type="text"
				                                            style=""
				                                            name="quantity"
				                                            :isDebounce="false"
				                                            :disabled="store.detailModel.quantity.disabled"
				                                            :value="store.data.quantity"
				                                            @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
				                                        />
				                                    </slot>
				                                </div>
				                            </AppFormItem>
				                        </slot>
				                    </template>
				                </AppCol>
				                <AppCol
				                    noRoot
				                    :visible="store.detailModel.amount.visible"
				                    :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 6,colSM: 6,colXS: 6,}">
				                    <template v-slot:default="{ slotStyle, slotClass }">
				                        <slot name="amount"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
				                            <AppFormItem 
				                                name="amount"
				                                :slotStyle="slotStyle"
				                                :slotClass="slotClass" 
				                                :label="$t('DEF.LNAME.AMOUNT', '小计')"
				                                labelPos="LEFT" 
				                                :labelWidth="180" 
				                                :showLabel="true"
				                                :enableAnchor="false" 
				                                :rules="store.detailModel.amount.valueRule"
				                                :emptyCaption="false">
				                                <div class="form-editor-container">
				                                    <slot name="amountEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
				                                        <AppSpan
				                                            :context="store.context"
				                                            :viewParams="store.viewParams"
				                                            :dataType="7"
				                                            v-bind="{ editorType: 'SPAN', }"
				                                            deMajorField=""
				                                            editorType="SPAN"
				                                            style=""
				                                            name="amount"
				                                            noValueShowMode="STYLE1"
				                                            :value="store.data.amount"
				                                        />
				                                    </slot>
				                                </div>
				                            </AppFormItem>
				                        </slot>
				                    </template>
				                </AppCol>
				            </AppFormGroup>
				        </slot>
				    </template>
				</AppCol>
			</AppRow>
        </div>
    </AppForm>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{spinalCase ctrl.codeName}}-form-base.vue.hbs生成

import { Ref } from 'vue';
import { AppAnchor } from '@components/common/anchor';
import { AppCol } from '@/components/common/col';
import { AppRow } from '@/components/common/row';
import { AppForm, AppFormPage, AppFormGroup, AppFormTabPage, AppFormItem, AppFormButton, AppFormDruipart, AppFormIframe, AppFormRaw, AppFormMdCtrl, AppFormMdCtrlRepeater } from '@components/widgets/form';
import { IEvent, EditFormActionType, IEditFormAbility, IEditFormStore, IParam } from '@/core';
import { useProps, useBasic, useAction, useController } from './logic-0007-form-hook';

const editForm: Ref = ref(null);

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { controlID, getClassNames, model ,useNavParamsBind, useEventBind, handleActionClick, handleComponentAction } = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: EditFormActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IEditFormAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
  return getClassNames(props);
});

//  表单控制器
const controller = useController(props, evt, { controlID, editForm });

useNavParamsBind(controller, props);

const store: IEditFormStore = controller.getStore();

const ctrlService = controller.getCtrlService();

onMounted(() => {
    controller.ctrlMounted();
});
onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>